import os
import sys
import logging
import time
import numpy as np

from .. import helper
from .onnx_t5enc import ONNXT5EncInfer
from .onnx_t5dec import ONNXT5DecInfer


class ONNXInfer(ONNXT5EncInfer, ONNXT5DecInfer):
    def __init__(self, model_dir=None) -> None:
        super(ONNXInfer, self).__init__(model_dir)
        logging.debug(f"ONNXInfer init.")

    def __del__(self):
        super(ONNXInfer, self).__del__()
        logging.debug(f"ONNXInfer destruct.")

    def infer(self, contents):
        enc_mask, enc_hidden = self.enc(contents)
        dec_ids = self.dec(enc_mask, enc_hidden)

        return dec_ids